const {
    getUserCart,
    deleteUserCart,
    updataUserCart,
    addUserCart,
    updataOrder,
    addOrders,
    getmendian,
    getGoods,
    getOrders,
    getOrderById,
    deleteOrdersById
} = require('../dao/ordersDao.js')


//购物车的数据处理
module.exports.deleteUserCart = async (userId) => {
    const result = await deleteUserCart(userId);
    return result;
}
module.exports.addUserCart = async (msg) => {
    const result = await addUserCart(msg);
    return result;
}
module.exports.updataUserCart = async (userId) => {
    const result = await updataUserCart(userId);
    return result;
}
module.exports.getUserCart = async (userId) => {
    const result = await getUserCart(userId);
    return result;
}
//订单数据处理
module.exports.updataOrder = async newShops => {
    const result = await updataOrder(newShops);
    return result;
}
module.exports.addOrders = async newShops => {
    const result = await addOrders(newShops);
    if (result._id) {
        return true;
    }
    return false;
}
module.exports.getOrders = async (msg) => {
    const result = await getOrders(msg);
    return result;
}
module.exports.getmendian = async (msg) => {
    const result = await getmendian(msg);
    return result;
}
module.exports.getGoods = async (msg) => {
    const result = await getGoods(msg);
    return result;
}
module.exports.getOrderById = async orderId => {
    const result = await getOrderById(orderId);
    return result;
}

module.exports.deleteOrdersById = async orderId => {
    const result = await deleteOrdersById(orderId);
    if (result.ok === 1) {
        return true;
    }
    return false;
}